import React, { memo } from "react";
import { useEffect } from "react";
import { useState } from "react";

const App = memo(() => {

  const [count, setCount] = useState(0)

  useEffect(() => {
    // 当前传入的回调函数会在组件被渲染完成后，自动执行
    // 网络请求/DOM操作/事件监听

    console.log('监听redux中数据变化');

    // 在组件重新渲染或组件卸载时执行
    return () => {
      console.log('取消监听redux中数据变化');
    }
  })

  return (
    <div>
      计数：{ count }
      <div>
        <button onClick={e => setCount(count+1)}>+1</button>
      </div>
    </div>
  )
});

export default App;
